Public Class frmConfig_KhenThuong
    Dim sqlQuery As String = ""
    Dim ID As String = ""

    Private Sub frmConfig_KhenThuong_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        moduleUtils.setDinhDangVietNam()

        Me.Doanhso_muc_3TextBox.Visible = False

        sqlQuery = "SELECT ID, heso_mekong, heso_mekophar, phantram_mekong, phantram_mekophar, soluong_nhathuoc_chuan"
        sqlQuery += ", thuong_theo_nhathuoc, doanhso_mekophar_chuan, doanhso_mekong_chuan, thuong_doanhso_chuan"
        sqlQuery += ", doanhso_muc_1, doanhso_muc_2, doanhso_muc_3"
        sqlQuery += ", tyle_thuong_muc_1, tyle_thuong_muc_2, tyle_thuong_muc_3"
        sqlQuery += " FROM tbl_config_doanhthu"
        Dim data As DataTable = moduleDatabaseConn.GetDataTable(sqlQuery)

        Try
            ID = data.Rows.Item(0).Item(0)
            Me.Heso_mekongTextBox.Text = data.Rows.Item(0).Item(1)
            Me.Heso_mekopharTextBox.Text = data.Rows.Item(0).Item(2)
            Me.Phantram_mekongTextBox.Text = data.Rows.Item(0).Item(3)
            Me.Phantram_mekopharTextBox.Text = data.Rows.Item(0).Item(4)
            Me.Soluong_nhathuoc_chuanTextBox.Text = data.Rows.Item(0).Item(5)
            Me.Thuong_theo_nhathuocTextBox.Text = Format(CDec(data.Rows.Item(0).Item(6)), "N0")
            Me.Doanhso_mekophar_chuanTextBox.Text = Format(CDec(data.Rows.Item(0).Item(7)), "N0")
            Me.Doanhso_mekong_chuanTextBox.Text = Format(CDec(data.Rows.Item(0).Item(8)), "N0")
            Me.Thuong_doanhso_chuanTextBox.Text = Format(CDec(data.Rows.Item(0).Item(9)), "N0")
            Me.Doanhso_muc_1TextBox.Text = Format(CDec(data.Rows.Item(0).Item(10)), "N0")
            Me.Doanhso_muc_2TextBox.Text = Format(CDec(data.Rows.Item(0).Item(11)), "N0")
            Me.Doanhso_muc_3TextBox.Text = Format(CDec(data.Rows.Item(0).Item(12)), "N0")
            Me.Tyle_thuong_muc_1TextBox.Text = Format(CDec(data.Rows.Item(0).Item(13)), "N1")
            Me.Tyle_thuong_muc_2TextBox.Text = Format(CDec(data.Rows.Item(0).Item(14)), "N1")
            Me.Tyle_thuong_muc_3TextBox.Text = Format(CDec(data.Rows.Item(0).Item(15)), "N1")
        Catch ex As Exception

        End Try
    End Sub

    Private Sub BtnClose_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnClose.Click
        Me.Close()
    End Sub

    Private Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
        If checkInput() Then
            Dim updated As Integer = 0
            sqlQuery = "UPDATE tbl_config_doanhthu SET"
            sqlQuery += " heso_mekong = " & CInt(Me.Heso_mekongTextBox.Text)
            sqlQuery += ", heso_mekophar = " & CInt(Me.Heso_mekopharTextBox.Text)
            sqlQuery += ", phantram_mekong = " & CInt(Me.Phantram_mekongTextBox.Text)
            sqlQuery += ", phantram_mekophar = " & CInt(Me.Phantram_mekopharTextBox.Text)
            sqlQuery += ", soluong_nhathuoc_chuan = " & CInt(Me.Soluong_nhathuoc_chuanTextBox.Text)
            sqlQuery += ", thuong_theo_nhathuoc = " & CDec(Me.Thuong_theo_nhathuocTextBox.Text)
            sqlQuery += ", doanhso_mekophar_chuan = " & CDec(Me.Doanhso_mekophar_chuanTextBox.Text)
            sqlQuery += ", doanhso_mekong_chuan = " & CDec(Me.Doanhso_mekong_chuanTextBox.Text)
            sqlQuery += ", thuong_doanhso_chuan = " & CDec(Me.Thuong_doanhso_chuanTextBox.Text)
            sqlQuery += ", doanhso_muc_1 = " & CDec(Me.Doanhso_muc_1TextBox.Text)
            sqlQuery += ", doanhso_muc_2 = " & CDec(Me.Doanhso_muc_2TextBox.Text)
            sqlQuery += ", doanhso_muc_3 = " & CDec(Me.Doanhso_muc_3TextBox.Text)
            sqlQuery += ", tyle_thuong_muc_1 = " & Replace(CDec(Me.Tyle_thuong_muc_1TextBox.Text), ",", ".")
            sqlQuery += ", tyle_thuong_muc_2 = " & Replace(CDec(Me.Tyle_thuong_muc_2TextBox.Text), ",", ".")
            sqlQuery += ", tyle_thuong_muc_3 = " & Replace(CDec(Me.Tyle_thuong_muc_3TextBox.Text), ",", ".")
            sqlQuery += " WHERE ID = " & ID
            updated = moduleDatabaseConn.ExecuteNonQuery(sqlQuery)
            If updated = 1 Then
                globalVariale.HESO_MEKONG = CInt(Me.Heso_mekongTextBox.Text)
                globalVariale.HESO_MEKOPHAR = CInt(Me.Heso_mekopharTextBox.Text)
                globalVariale.PHANTRAM_MEKONG = CInt(Me.Phantram_mekongTextBox.Text)
                globalVariale.PHANTRAM_MEKOPHAR = CInt(Me.Phantram_mekopharTextBox.Text)
                globalVariale.SOLUONG_NHATHUOC_CHUAN = CInt(Me.Soluong_nhathuoc_chuanTextBox.Text)
                globalVariale.THUONG_THEO_NHATHUOC = CDec(Me.Thuong_theo_nhathuocTextBox.Text)
                globalVariale.DOANHSO_MEKOPHAR_CHUAN = CDec(Me.Doanhso_mekophar_chuanTextBox.Text)
                globalVariale.DOANHSO_MEKONG_CHUAN = CDec(Me.Doanhso_mekong_chuanTextBox.Text)
                globalVariale.THUONG_DOANHSO_CHUAN = CDec(Me.Thuong_doanhso_chuanTextBox.Text)
                globalVariale.DOANHSO_MUC_1 = CDec(Me.Doanhso_muc_1TextBox.Text)
                globalVariale.DOANHSO_MUC_2 = CDec(Me.Doanhso_muc_2TextBox.Text)
                globalVariale.DOANHSO_MUC_3 = CDec(Me.Doanhso_muc_3TextBox.Text)
                globalVariale.TYLE_THUONG_MUC_1 = CDec(Me.Tyle_thuong_muc_1TextBox.Text)
                globalVariale.TYLE_THUONG_MUC_2 = CDec(Me.Tyle_thuong_muc_2TextBox.Text)
                globalVariale.TYLE_THUONG_MUC_3 = CDec(Me.Tyle_thuong_muc_3TextBox.Text)
            End If
        End If
    End Sub

    Private Function checkInput() As Boolean
        checkInput = True
    End Function


End Class